#include "playerwgt.h"
#include <QVBoxLayout>
#include <QMouseEvent>
#include <QDebug>
#include "skin/skin.h"

PlayerWgt::PlayerWgt(QWidget *parent)
    : QWidget{parent}
{
    this->setFixedSize(1080,700);//设置窗口大小

    this->setWindowFlags((Qt::FramelessWindowHint));//设置窗口为简约风格

    //创建子窗口对象
    titleWgt_ = new  titleWgt(this);
    centerWgt_ = new centerWgt(this);
    tailWgt_ = new tailWgt(this);


    //设置垂直布局
    QVBoxLayout* vlayout = new QVBoxLayout(this);
    vlayout->addWidget(titleWgt_);
    vlayout->setSpacing(0);
    vlayout->addWidget(centerWgt_);
    vlayout->addWidget(tailWgt_);
    vlayout->setContentsMargins(0,0,0,0);
    //设置布局
    this->setLayout(vlayout);

    //加载皮肤
    SkinMgr::inst()->setSkin(SK_PLAYER,this);



}

void PlayerWgt::mouseMoveEvent(QMouseEvent *event)
{
    qDebug()<<"鼠标移动";
    if(event->buttons() & Qt::LeftButton && isPress_)
    {
        move(event->globalPos() - point_);
    }
    QWidget::mouseMoveEvent(event);
}

void PlayerWgt::mousePressEvent(QMouseEvent *event)
{
    qDebug()<<"鼠标按下";
    isPress_ = true;
    point_ = event->globalPos() - this->frameGeometry().topLeft();

    QWidget::mousePressEvent(event);
}

void PlayerWgt::mouseReleaseEvent(QMouseEvent *event)
{
    qDebug()<<"鼠标松开";
    isPress_ = false;
    QWidget::mouseReleaseEvent(event);
}
